﻿using DatabaseCore;
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Export.Ui.ViewModel
{
    public class OrderDetail : ViewModelBase, INotifyPropertyChanged
    {
        private tbl_OrderDetail _orderDetail;
        //private int _atp;

        public OrderDetail()
        {
            _orderDetail = new tbl_OrderDetail();
        }

        public OrderDetail(tbl_OrderDetail orderDetail)
        {
            _orderDetail = orderDetail;
        }

        public tbl_OrderDetail orderDetail
        {
            get
            {
                return _orderDetail;
            }
        }

        public string OrderNo
        {
            get
            {
                return _orderDetail.OrderNo;
            }
            set
            {
                _orderDetail.OrderNo = value;
                OnPropertyChanged("OrderNo");
            }
        }

        public int? ItemNo
        {
            get
            {
                return _orderDetail.ItemNo;
            }
            set
            {
                _orderDetail.ItemNo = value;
                OnPropertyChanged("ItemNo");
            }
        }

        public string ItemId
        {
            get
            {
                return _orderDetail.ItemId;
            }
            set
            {
                _orderDetail.ItemId = value;
                OnPropertyChanged("ItemId");
            }
        }

        public string ItemName
        {
            get
            {
                return _orderDetail.ItemName;
            }
            set
            {
                _orderDetail.ItemName = value;
                OnPropertyChanged("ItemName");
            }
        }

        public string ProductId
        {
            get
            {
                return _orderDetail.ProductId;
            }
            set
            {
                _orderDetail.ProductId = value;
                OnPropertyChanged("ProductId");
            }
        }

        public string ProductName
        {
            get
            {
                return _orderDetail.ProductName;
            }
            set
            {
                _orderDetail.ProductName = value;
                OnPropertyChanged("ProductName");
            }
        }

        public int Qty
        {
            get
            {
                return _orderDetail.Qty;
            }
            set
            {
                _orderDetail.Qty = value;
                OnPropertyChanged("Qty");
            }
        }

        public string MaterialNo
        {
            get
            {
                return _orderDetail.MaterialNo;
            }
            set
            {
                _orderDetail.MaterialNo = value;
                OnPropertyChanged("MaterialNo");
            }
        }

        public string Plant
        {
            get
            {
                return _orderDetail.Plant;
            }
            set
            {
                _orderDetail.Plant = value;
                OnPropertyChanged("Plant");
            }
        }

        public int? Rate
        {
            get
            {
                return _orderDetail.Rate;
            }
            set
            {
                _orderDetail.Rate = value;
                OnPropertyChanged("Rate");
            }
        }

        public DateTime? ValidFrom
        {
            get
            {
                return _orderDetail.ValidFrom;
            }
            set
            {
                _orderDetail.ValidFrom = value;
                OnPropertyChanged("ValidFrom");
            }
        }

        public DateTime? ValidTo
        {
            get
            {
                return _orderDetail.ValidTo;
            }
            set
            {
                _orderDetail.ValidTo = value;
                OnPropertyChanged("ValidTo");
            }
        }

        public int Atp
        {
            get
            {
                //return _atp;
                return _orderDetail.ATP;
            }
            set
            {
                //_atp = value;
                _orderDetail.ATP = value;
                OnPropertyChanged("Atp");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
